package com.truthbean.jeetb.model.sys.listener;

import javax.persistence.*;

/**
 * Created by truth on 16-9-6.
 */

public class RepositoryListener {

    @PreRemove
    @PrePersist
    @PreUpdate
    public void before(EntityManager entityManager) {
        //entityManager.transaction.begin()
        System.out.println("事务开始");
        System.out.println(entityManager);
    }

    @PostPersist
    @PostRemove
    @PostUpdate
    public void after(EntityManager entityManager) {
        //entityManager.transaction.commit()
        //entityManager.flush()
        System.out.println(entityManager);
        System.out.println("事务结束");
    }
}